var member;
$(function(){
	//获取cookie中的对象
	member=getEntity("memberInfo");
	if(member){
		if(member.mImg){
			$("#imgSpan").prepend('<img src="'+baseFile+member.mImg+'" id="mImg" alt="" />');
			$(".imgSpan").prepend('<img src="'+baseFile+member.mImg+'" id="mImg" alt="" />');
		}else{
			$("#imgSpan").prepend('<img src="'+rootPath+'/images/header.png" id="mImg" alt="" />');
			$(".imgSpan").prepend('<img src="'+rootPath+'/images/header.png" id="mImg" alt="" />');
		} 
		//<img src="${ctx}/images/header.png" id="mImg" alt="" />
		$("#mName").val(member.mName);
		$("#mRealname").val(member.mRealname);
		$("#mId").val(member.mId);
		$("#mPhone").val(member.mPhone);
		$("#mImg").val(member.mImg);	
		console.log(member.birthday);
		$("input[name=birthdayStr]").val(member.birthdayStr);
		if(member.mSex=='0'){
			$("#male").attr("checked","checked");
		}else{
			$("#female").attr("checked","checked");
		}
	}else{
		window.location.href=rootPath+"/";
	}
	$('.form_datetime').datetimepicker({
		language:'zh-CN',
		format: 'yyyy-MM-dd',
		autoclose: true,
		todayBtn: true,
		pickerPosition:'bottom-left',
		startView:4,
		minView:2,
	})
	$('#save').click(function(){
		var data = $("form").serialize();
		$.ajax({
			type:"post",
			url:rootPath+"/member/upMemberInfo",
			data:data,	
			success:function(data){
				if(data.resultSuccess==true){
					 layer.msg("修改资料成功!",{icon:1,skin: 'layui-layer-red ',offset: ['40%', '45%']});
					 
				}else{
					layer.msg("修改资料失败!请检查修改后的信息是否有误！",{icon:1,skin: 'layui-layer-red ',offset: ['40%', '45%']});
					$("#msg").text(data.resultDesc);
				}
			}
		});
	})
})   

 